import 'package:flutter/material.dart';
import 'package:like_chat/entity/user.dart';
import 'package:like_chat/final_values.dart';
import 'package:like_chat/widget/header_widget.dart';

class DetailsPage extends StatefulWidget {
  final User user;

  DetailsPage({this.user});

  @override
  _DetailsPageState createState() => _DetailsPageState();
}

class _DetailsPageState extends State<DetailsPage> {
  @override
  Widget build(BuildContext context) {
    final box = SizedBox(
        height: 20.0,
        child: Container(
          color: const Color(backgroundColorValue),
        ));
    return Scaffold(
      body: Column(
        children: <Widget>[
          box,
          _headWidget("Learn peng", IMG_URL),
          box,
          _itemWidget(
              "钱包",
              Icon(
                Icons.account_balance_wallet,
                color: Colors.blue,
              ),
              first: true),
          box,
          _itemWidget(
            "收藏",
            Icon(
              Icons.star,
              color: Colors.orangeAccent,
            ),
          ),
          _itemWidget(
            "相册",
            Icon(Icons.photo, color: Colors.blueAccent),
          ),
          _itemWidget(
            "卡包",
            Icon(Icons.card_giftcard, color: Colors.green),
          ),
          _itemWidget(
              "表情",
              Icon(
                Icons.insert_emoticon,
                color: Colors.orange,
              ),
              first: true),
          box,
          _itemWidget("设置", Icon(Icons.settings, color: Colors.blueAccent),
              first: true),
          Expanded(
            child: box,
          )
        ],
      ),
    );
  }

  Widget _headWidget(String s, url) {
    return Row(
      children: <Widget>[
        const SizedBox(
          width: 13.0,
        ),
        Container(
          margin: const EdgeInsets.symmetric(vertical: 4.0),
          child: HeaderWidget(radius: 75.0, url: url),
        ),
        const SizedBox(
          width: 13.0,
        ),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Text(s, style: const TextStyle(fontSize: 16.0)),
            const SizedBox(
              height: 5.0,
            ),
            Text("LikeID: wxp123456789",
                style: const TextStyle(fontSize: 12.0, color: Colors.grey)),
          ],
        ),
      ],
    );
  }

  Widget _itemWidget(String name, Icon icon, {bool first = false}) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Padding(
            padding: EdgeInsets.symmetric(vertical: 12.0),
            child: Row(
              children: <Widget>[
                const SizedBox(
                  width: 15.0,
                ),
                icon,
                const SizedBox(
                  width: 10.0,
                ),
                Text(name),
              ],
            )),
        Offstage(
          offstage: first,
          child: Divider(
            height: 1.0,
          ),
        )
      ],
    );
  }
}
